$(document).ready(
		function() {
			console.log('hey');

			var WS = window['MozWebSocket'] ? MozWebSocket : WebSocket
			// var socket = new WS("ws://localhost:9000/helloSocket?name=mph");
			var address=findWebSocketURL("/helloSocket?name=mph");
			console.log(address);
			var socket = new WS(address);
			// var socket = new WebSocket(host);

			message('<p class="event">Socket Status: ' + socket.readyState);

			socket.onopen = function() {
				console.log("opened socket");
				message('<p class="event">Socket Status: ' + socket.readyState
						+ ' (open)');
			}

			socket.onmessage = function(msg) {
				message('Received: ' + msg.data);
				var number = parseInt(msg.data, "10");
				socket.send(number + 1);
			}

			socket.onclose = function() {
				message('<p class="event">Socket Status: ' + socket.readyState
						+ ' (Closed)');
			}
		});

function findWebSocketURL(url) {
	return decodeURI($('<a href="' + url + '"/>')[0].href
			.replace(/^http/, "ws"));
}
function requestJson() {
	$.get('/pointApi', function(data) {
		var text = JSON.stringify(data, null, '\t');
		console.log("got " + text);
		// $('#debug').append(text);
		// $('#debug').append(prettyPrint(data));
	});
}

function message(msg) {
	$('#chatLog').html(msg);
}

function tryThis() {
	var geometry = new THREE.Geometry();

	for ( var i = 0; i < 10; i++) {
		particle = new THREE.Particle(material);
		particle.position.x = Math.random() * 2 - 1;
		particle.position.y = Math.random() * 2 - 1;
		particle.position.z = Math.random() * 2 - 1;
		particle.position.normalize();
		particle.position.multiplyScalar(Math.random() * 10 + 45);
		particle.scale.x = particle.scale.y = 1;
		scene.add(particle);
		geometry.vertices.push(particle.position);
	}

	var line = new THREE.Line(geometry, new THREE.LineBasicMaterial({
		color : 0xffffff,
		opacity : 0.5
	}));
	scene.add(line);

}